package com.nwpu.coursesupport.mapper;


import com.nwpu.coursesupport.entity.StudentFinalExamScoreEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 *
 * @author shun
 * @email ws2017303035@mail.nwpu.edu.cn
 * @date 2020-08-04 21:33:50
 */
@Mapper
public interface StudentFinalExamScoreDao {

    @Insert("insert into student_final_exam_score values (null,#{studentId},#{finalExamTaskId},#{fullMark},#{actualMark},#{isSelect},#{selectedAnswer},#{scoreItem})")
    @Options(keyProperty = "id", keyColumn = "id", useGeneratedKeys = true)
    Integer save(StudentFinalExamScoreEntity studentFinalExamScoreEntity);

    @Select("select * from student_final_exam_score where final_exam_task_id=#{id}")
    List<StudentFinalExamScoreEntity> findByFinalExamTaskId(@Param("id") Integer id);

    @Select("delete from student_final_exam_score where id=#{id}")
    void deleteById(@Param("id") Integer id);

    @Select("select * from student_final_exam_score where student_id=#{studentId}")
    List<StudentFinalExamScoreEntity> findByStudentId(@Param("studentId") int studentId);

    @Select("select * from student_final_exam_score where id = #{id}")
    StudentFinalExamScoreEntity findById(@Param("id") Integer id);

    @Update("update student_final_exam_score set " +
            "student_id=#{studentId},final_exam_task_id=#{finalExamTaskId}," +
            "full_mark=#{fullMark},actual_mark=#{actualMark},is_select=#{isSelect}," +
            "selected_answer=#{selectedAnswer},score_item=#{scoreItem} where id=#{id}")
    void updateById(StudentFinalExamScoreEntity entity);
}
